/****************************************************************
*  COPYRIGHT MorningCore CO.,LTD                               *
*****************************************************************/
/****************************************************************
* FileName:    <lib_arith_N.h>
* version:     <1.0.0>
* Purpose:     <Header file of lib_arith_N.c>
* Authors:     <Yan Dong>
* Notes:       <None>
****************************************************************/

/******************************************************************************
*  HISTORY OF CHANGES
*   <Date>          <Author>        <Version>       <DESCRIPTION>
*   2006-06         Yan Dong         V1.0.0           original
******************************************************************************/
#ifndef LIB_ARITH_N_H
#define LIB_ARITH_N_H

#include "../CommLib_FltC/Typedef.h"
#include "../CommLib_FltC/Lib_Arith_f.h"

#include <iostream>
#include <cstdlib>
#include <math.h>

/*-----------including external files -----------------------------*/

/*-----------macro declaration-------------------------------------*/

/*-----------global variable declaration---------------------------*/

/*-----------constant and type declaration-------------------------*/

/*-----------file-local variable declaration-----------------------*/

/*-----------Function or task prototype declaration-----------------*/
// Deleted by kangguoqing for level-4 warning, 2013-01-06, CRID:Enh00000316
//extern int N;                                         //bit length of fractN
//extern int M;                                         //bit length of fractM
//extern int L;                                         //the extend length of accumulator
//extern fractM MAX_M;          //the maximal number of fractM
//extern fractM MIN_M;              //the minimal number of fractM
//extern fractN MAX_N;          //the maximal number of fractN
//extern fractN MIN_N;              //the minimal number of fractN
//extern fractM ROUNDING;
//extern fractLXM MAX_LXM;                  //the maximal number of fractN
//extern fractLXM MIN_LXM;                      //the minimal number of fractN
//extern long SIGN_POSITION;                           //the sign bit's position

//end of deleted, CRID:Enh00000316

const fractN RecipN[276] = { 0,              // Q(N,1), reciprocal of N

                             (fractN)(1.0 / 1 * (1 << 15) - 1 + 0.5), (fractN)(1.0 / 2 * (1 << 15) + 0.5), (fractN)(1.0 / 3 * (1 << 15) + 0.5), (fractN)(1.0 / 4 * (1 << 15) + 0.5), (fractN)(1.0 / 5 * (1 << 15) + 0.5),                //

                             (fractN)(1.0 / 6 * (1 << 15) + 0.5), (fractN)(1.0 / 7 * (1 << 15) + 0.5), (fractN)(1.0 / 8 * (1 << 15) + 0.5), (fractN)(1.0 / 9 * (1 << 15) + 0.5), (fractN)(1.0 / 10 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 11 * (1 << 15) + 0.5), (fractN)(1.0 / 12 * (1 << 15) + 0.5), (fractN)(1.0 / 13 * (1 << 15) + 0.5), (fractN)(1.0 / 14 * (1 << 15) + 0.5), (fractN)(1.0 / 15 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 16 * (1 << 15) + 0.5), (fractN)(1.0 / 17 * (1 << 15) + 0.5), (fractN)(1.0 / 18 * (1 << 15) + 0.5), (fractN)(1.0 / 19 * (1 << 15) + 0.5), (fractN)(1.0 / 20 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 21 * (1 << 15) + 0.5), (fractN)(1.0 / 22 * (1 << 15) + 0.5), (fractN)(1.0 / 23 * (1 << 15) + 0.5), (fractN)(1.0 / 24 * (1 << 15) + 0.5), (fractN)(1.0 / 25 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 26 * (1 << 15) + 0.5), (fractN)(1.0 / 27 * (1 << 15) + 0.5), (fractN)(1.0 / 28 * (1 << 15) + 0.5), (fractN)(1.0 / 29 * (1 << 15) + 0.5), (fractN)(1.0 / 30 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 31 * (1 << 15) + 0.5), (fractN)(1.0 / 32 * (1 << 15) + 0.5), (fractN)(1.0 / 33 * (1 << 15) + 0.5), (fractN)(1.0 / 34 * (1 << 15) + 0.5), (fractN)(1.0 / 35 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 36 * (1 << 15) + 0.5), (fractN)(1.0 / 37 * (1 << 15) + 0.5), (fractN)(1.0 / 38 * (1 << 15) + 0.5), (fractN)(1.0 / 39 * (1 << 15) + 0.5), (fractN)(1.0 / 40 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 41 * (1 << 15) + 0.5), (fractN)(1.0 / 42 * (1 << 15) + 0.5), (fractN)(1.0 / 43 * (1 << 15) + 0.5), (fractN)(1.0 / 44 * (1 << 15) + 0.5), (fractN)(1.0 / 45 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 46 * (1 << 15) + 0.5), (fractN)(1.0 / 47 * (1 << 15) + 0.5), (fractN)(1.0 / 48 * (1 << 15) + 0.5), (fractN)(1.0 / 49 * (1 << 15) + 0.5), (fractN)(1.0 / 50 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 51 * (1 << 15) + 0.5), (fractN)(1.0 / 52 * (1 << 15) + 0.5), (fractN)(1.0 / 53 * (1 << 15) + 0.5), (fractN)(1.0 / 54 * (1 << 15) + 0.5), (fractN)(1.0 / 55 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 56 * (1 << 15) + 0.5), (fractN)(1.0 / 57 * (1 << 15) + 0.5), (fractN)(1.0 / 58 * (1 << 15) + 0.5), (fractN)(1.0 / 59 * (1 << 15) + 0.5), (fractN)(1.0 / 60 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 61 * (1 << 15) + 0.5), (fractN)(1.0 / 62 * (1 << 15) + 0.5), (fractN)(1.0 / 63 * (1 << 15) + 0.5), (fractN)(1.0 / 64 * (1 << 15) + 0.5), (fractN)(1.0 / 65 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 66 * (1 << 15) + 0.5), (fractN)(1.0 / 67 * (1 << 15) + 0.5), (fractN)(1.0 / 68 * (1 << 15) + 0.5), (fractN)(1.0 / 69 * (1 << 15) + 0.5), (fractN)(1.0 / 70 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 71 * (1 << 15) + 0.5), (fractN)(1.0 / 72 * (1 << 15) + 0.5), (fractN)(1.0 / 73 * (1 << 15) + 0.5), (fractN)(1.0 / 74 * (1 << 15) + 0.5), (fractN)(1.0 / 75 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 76 * (1 << 15) + 0.5), (fractN)(1.0 / 77 * (1 << 15) + 0.5), (fractN)(1.0 / 78 * (1 << 15) + 0.5), (fractN)(1.0 / 79 * (1 << 15) + 0.5), (fractN)(1.0 / 80 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 81 * (1 << 15) + 0.5), (fractN)(1.0 / 82 * (1 << 15) + 0.5), (fractN)(1.0 / 83 * (1 << 15) + 0.5), (fractN)(1.0 / 84 * (1 << 15) + 0.5), (fractN)(1.0 / 85 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 86 * (1 << 15) + 0.5), (fractN)(1.0 / 87 * (1 << 15) + 0.5), (fractN)(1.0 / 88 * (1 << 15) + 0.5), (fractN)(1.0 / 89 * (1 << 15) + 0.5), (fractN)(1.0 / 90 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 91 * (1 << 15) + 0.5), (fractN)(1.0 / 92 * (1 << 15) + 0.5), (fractN)(1.0 / 93 * (1 << 15) + 0.5), (fractN)(1.0 / 94 * (1 << 15) + 0.5), (fractN)(1.0 / 95 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 96 * (1 << 15) + 0.5), (fractN)(1.0 / 97 * (1 << 15) + 0.5), (fractN)(1.0 / 98 * (1 << 15) + 0.5), (fractN)(1.0 / 99 * (1 << 15) + 0.5), (fractN)(1.0 / 100 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 101 * (1 << 15) + 0.5), (fractN)(1.0 / 102 * (1 << 15) + 0.5), (fractN)(1.0 / 103 * (1 << 15) + 0.5), (fractN)(1.0 / 104 * (1 << 15) + 0.5), (fractN)(1.0 / 105 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 106 * (1 << 15) + 0.5), (fractN)(1.0 / 107 * (1 << 15) + 0.5), (fractN)(1.0 / 108 * (1 << 15) + 0.5), (fractN)(1.0 / 109 * (1 << 15) + 0.5), (fractN)(1.0 / 110 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 111 * (1 << 15) + 0.5), (fractN)(1.0 / 112 * (1 << 15) + 0.5), (fractN)(1.0 / 113 * (1 << 15) + 0.5), (fractN)(1.0 / 114 * (1 << 15) + 0.5), (fractN)(1.0 / 115 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 116 * (1 << 15) + 0.5), (fractN)(1.0 / 117 * (1 << 15) + 0.5), (fractN)(1.0 / 118 * (1 << 15) + 0.5), (fractN)(1.0 / 119 * (1 << 15) + 0.5), (fractN)(1.0 / 120 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 121 * (1 << 15) + 0.5), (fractN)(1.0 / 122 * (1 << 15) + 0.5), (fractN)(1.0 / 123 * (1 << 15) + 0.5), (fractN)(1.0 / 124 * (1 << 15) + 0.5), (fractN)(1.0 / 125 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 126 * (1 << 15) + 0.5), (fractN)(1.0 / 127 * (1 << 15) + 0.5), (fractN)(1.0 / 128 * (1 << 15) + 0.5), (fractN)(1.0 / 129 * (1 << 15) + 0.5), (fractN)(1.0 / 130 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 131 * (1 << 15) + 0.5), (fractN)(1.0 / 132 * (1 << 15) + 0.5), (fractN)(1.0 / 133 * (1 << 15) + 0.5), (fractN)(1.0 / 134 * (1 << 15) + 0.5), (fractN)(1.0 / 135 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 136 * (1 << 15) + 0.5), (fractN)(1.0 / 137 * (1 << 15) + 0.5), (fractN)(1.0 / 138 * (1 << 15) + 0.5), (fractN)(1.0 / 139 * (1 << 15) + 0.5), (fractN)(1.0 / 140 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 141 * (1 << 15) + 0.5), (fractN)(1.0 / 142 * (1 << 15) + 0.5), (fractN)(1.0 / 143 * (1 << 15) + 0.5), (fractN)(1.0 / 144 * (1 << 15) + 0.5), (fractN)(1.0 / 145 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 146 * (1 << 15) + 0.5), (fractN)(1.0 / 147 * (1 << 15) + 0.5), (fractN)(1.0 / 148 * (1 << 15) + 0.5), (fractN)(1.0 / 149 * (1 << 15) + 0.5), (fractN)(1.0 / 150 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 151 * (1 << 15) + 0.5), (fractN)(1.0 / 152 * (1 << 15) + 0.5), (fractN)(1.0 / 153 * (1 << 15) + 0.5), (fractN)(1.0 / 154 * (1 << 15) + 0.5), (fractN)(1.0 / 155 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 156 * (1 << 15) + 0.5), (fractN)(1.0 / 157 * (1 << 15) + 0.5), (fractN)(1.0 / 158 * (1 << 15) + 0.5), (fractN)(1.0 / 159 * (1 << 15) + 0.5), (fractN)(1.0 / 160 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 161 * (1 << 15) + 0.5), (fractN)(1.0 / 162 * (1 << 15) + 0.5), (fractN)(1.0 / 163 * (1 << 15) + 0.5), (fractN)(1.0 / 164 * (1 << 15) + 0.5), (fractN)(1.0 / 165 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 166 * (1 << 15) + 0.5), (fractN)(1.0 / 167 * (1 << 15) + 0.5), (fractN)(1.0 / 168 * (1 << 15) + 0.5), (fractN)(1.0 / 169 * (1 << 15) + 0.5), (fractN)(1.0 / 170 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 171 * (1 << 15) + 0.5), (fractN)(1.0 / 172 * (1 << 15) + 0.5), (fractN)(1.0 / 173 * (1 << 15) + 0.5), (fractN)(1.0 / 174 * (1 << 15) + 0.5), (fractN)(1.0 / 175 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 176 * (1 << 15) + 0.5), (fractN)(1.0 / 177 * (1 << 15) + 0.5), (fractN)(1.0 / 178 * (1 << 15) + 0.5), (fractN)(1.0 / 179 * (1 << 15) + 0.5), (fractN)(1.0 / 180 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 181 * (1 << 15) + 0.5), (fractN)(1.0 / 182 * (1 << 15) + 0.5), (fractN)(1.0 / 183 * (1 << 15) + 0.5), (fractN)(1.0 / 184 * (1 << 15) + 0.5), (fractN)(1.0 / 185 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 186 * (1 << 15) + 0.5), (fractN)(1.0 / 187 * (1 << 15) + 0.5), (fractN)(1.0 / 188 * (1 << 15) + 0.5), (fractN)(1.0 / 189 * (1 << 15) + 0.5), (fractN)(1.0 / 190 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 191 * (1 << 15) + 0.5), (fractN)(1.0 / 192 * (1 << 15) + 0.5), (fractN)(1.0 / 193 * (1 << 15) + 0.5), (fractN)(1.0 / 194 * (1 << 15) + 0.5), (fractN)(1.0 / 195 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 196 * (1 << 15) + 0.5), (fractN)(1.0 / 197 * (1 << 15) + 0.5), (fractN)(1.0 / 198 * (1 << 15) + 0.5), (fractN)(1.0 / 199 * (1 << 15) + 0.5), (fractN)(1.0 / 200 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 201 * (1 << 15) + 0.5), (fractN)(1.0 / 202 * (1 << 15) + 0.5), (fractN)(1.0 / 203 * (1 << 15) + 0.5), (fractN)(1.0 / 204 * (1 << 15) + 0.5), (fractN)(1.0 / 205 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 206 * (1 << 15) + 0.5), (fractN)(1.0 / 207 * (1 << 15) + 0.5), (fractN)(1.0 / 208 * (1 << 15) + 0.5), (fractN)(1.0 / 209 * (1 << 15) + 0.5), (fractN)(1.0 / 210 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 211 * (1 << 15) + 0.5), (fractN)(1.0 / 212 * (1 << 15) + 0.5), (fractN)(1.0 / 213 * (1 << 15) + 0.5), (fractN)(1.0 / 214 * (1 << 15) + 0.5), (fractN)(1.0 / 215 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 216 * (1 << 15) + 0.5), (fractN)(1.0 / 217 * (1 << 15) + 0.5), (fractN)(1.0 / 218 * (1 << 15) + 0.5), (fractN)(1.0 / 219 * (1 << 15) + 0.5), (fractN)(1.0 / 220 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 221 * (1 << 15) + 0.5), (fractN)(1.0 / 222 * (1 << 15) + 0.5), (fractN)(1.0 / 223 * (1 << 15) + 0.5), (fractN)(1.0 / 224 * (1 << 15) + 0.5), (fractN)(1.0 / 225 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 226 * (1 << 15) + 0.5), (fractN)(1.0 / 227 * (1 << 15) + 0.5), (fractN)(1.0 / 228 * (1 << 15) + 0.5), (fractN)(1.0 / 229 * (1 << 15) + 0.5), (fractN)(1.0 / 230 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 231 * (1 << 15) + 0.5), (fractN)(1.0 / 232 * (1 << 15) + 0.5), (fractN)(1.0 / 233 * (1 << 15) + 0.5), (fractN)(1.0 / 234 * (1 << 15) + 0.5), (fractN)(1.0 / 235 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 236 * (1 << 15) + 0.5), (fractN)(1.0 / 237 * (1 << 15) + 0.5), (fractN)(1.0 / 238 * (1 << 15) + 0.5), (fractN)(1.0 / 239 * (1 << 15) + 0.5), (fractN)(1.0 / 240 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 241 * (1 << 15) + 0.5), (fractN)(1.0 / 242 * (1 << 15) + 0.5), (fractN)(1.0 / 243 * (1 << 15) + 0.5), (fractN)(1.0 / 244 * (1 << 15) + 0.5), (fractN)(1.0 / 245 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 246 * (1 << 15) + 0.5), (fractN)(1.0 / 247 * (1 << 15) + 0.5), (fractN)(1.0 / 248 * (1 << 15) + 0.5), (fractN)(1.0 / 249 * (1 << 15) + 0.5), (fractN)(1.0 / 250 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 251 * (1 << 15) + 0.5), (fractN)(1.0 / 252 * (1 << 15) + 0.5), (fractN)(1.0 / 253 * (1 << 15) + 0.5), (fractN)(1.0 / 254 * (1 << 15) + 0.5), (fractN)(1.0 / 255 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 256 * (1 << 15) + 0.5), (fractN)(1.0 / 257 * (1 << 15) + 0.5), (fractN)(1.0 / 258 * (1 << 15) + 0.5), (fractN)(1.0 / 259 * (1 << 15) + 0.5), (fractN)(1.0 / 260 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 261 * (1 << 15) + 0.5), (fractN)(1.0 / 262 * (1 << 15) + 0.5), (fractN)(1.0 / 263 * (1 << 15) + 0.5), (fractN)(1.0 / 264 * (1 << 15) + 0.5), (fractN)(1.0 / 265 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 266 * (1 << 15) + 0.5), (fractN)(1.0 / 267 * (1 << 15) + 0.5), (fractN)(1.0 / 268 * (1 << 15) + 0.5), (fractN)(1.0 / 269 * (1 << 15) + 0.5), (fractN)(1.0 / 270 * (1 << 15) + 0.5),               //

                             (fractN)(1.0 / 271 * (1 << 15) + 0.5), (fractN)(1.0 / 272 * (1 << 15) + 0.5), (fractN)(1.0 / 273 * (1 << 15) + 0.5), (fractN)(1.0 / 274 * (1 << 15) + 0.5), (fractN)(1.0 / 275 * (1 << 15) + 0.5)             //
                           };

/***
* Following MACROS are used for converting complex structure to
* integer and integer to complex structure
***/
/*************************************** <a name="compose_fr1xM"></a>
*
* This function is used to pack two fractN's
* into one fractM.
*
* The input arguments are called "hi" and "lo",
* and correspond to the hi and low 16-bit portions
* of the return value:
*
* compse_2xN ( hi, lo ) results in
*
*  +------+------+
*  |  hi     lo  |
*  +------+------+  @PASS!
*
***************************************/
#define CMPLX2INT(X) compose_fr1xM(X.im, X.re)


/*************************************** <a name="compose_fr1xM"></a>
*
* This function is used to slip one fractM into two fractN's

* The input arguments are called "R" and "x",
* and R.re is correspond to the  low 16-bit portions
*  and R.im is correspond to the  high 16-bit portions
*
* compse_2xN ( hi, lo ) results in
*
*  +------+------+
*  |  hi     lo  |
*  +------+------+  @PASS!
*
***************************************/
#define INT2CMPLX(R,X)  \
  {  \
  R.re = extract_lo_fr1xM(X);  \
  R.im = extract_hi_fr1xM(X);  \
  }


/***
* set the bitwidth of fractN, fractM type
***/

#ifdef FLTPNT
#ifdef __cplusplus
extern "C"
{
#endif  //

#ifdef __cplusplus
}
#endif  //
#else  //
#ifdef __cplusplus
extern "C"
{
#endif  //

fractN sat_fr1xN_bitwidth(fractN,int);

#ifdef __cplusplus
}
#endif  //

#endif  //




#ifdef FLTPNT
#ifdef __cplusplus
extern "C"
{
#endif  //
// set tht bit width
void set_bit_width_f(int);
#ifdef __cplusplus
}
#endif  //
#else  //
#ifdef __cplusplus
extern "C"
{
#endif  //

// Function for setting fixed point bitwidth PASS!
void set_bit_width(int);

#ifdef __cplusplus
}
#endif  //

#endif  //


/***
* get the bitwidth of fractN type
***/

#ifdef FLTPNT
#ifdef __cplusplus
extern "C"
{
#endif  //
int bitWidth_f();
#ifdef __cplusplus
}
#endif  //
#else  //
#ifdef __cplusplus
extern "C"
{
#endif  //

// Function for get the fix point bit width of fractN type
int bitWidth();

#ifdef __cplusplus
}
#endif  //

#endif  //


/***
* get the MAX_N
***/

#ifdef FLTPNT
#ifdef __cplusplus
extern "C"
{
#endif  //
fractN get_MAX_N_f();
#ifdef __cplusplus
}
#endif  //
#else  //    //
#ifdef __cplusplus
extern "C"
{
#endif  //

//Function for get the MAX_N
fractN get_MAX_N();

#ifdef __cplusplus
}
#endif  //

#endif  //


/***
* get the MIN_N
***/

#ifdef FLTPNT
#ifdef __cplusplus
extern "C"
{
#endif  //
fractN get_MIN_N_f();
#ifdef __cplusplus
}
#endif  //
#else  //    //
#ifdef __cplusplus
extern "C"
{
#endif  //

// Function for get the MIN_N
fractN get_MIN_N();

#ifdef __cplusplus
}
#endif  //

#endif  //


/***
* get the MAX_N
***/

#ifdef FLTPNT
#ifdef __cplusplus
extern "C"
{
#endif  //
fractM  get_MAX_M_f();
#ifdef __cplusplus
}
#endif  //
#else  //    //
#ifdef __cplusplus
extern "C"
{
#endif  //

//Function for get the MAX_M
fractM get_MAX_M();

#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* get the MIN_N
***/

#ifdef FLTPNT
#ifdef __cplusplus
extern "C"
{
#endif  //
fractM get_MIN_M_f();
#ifdef __cplusplus
}
#endif  //
#else  //    //
#ifdef __cplusplus
extern "C"
{
#endif  //

//Function for get the MIN_M
fractM get_MIN_M();

#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* addition of two N bit fractN numbers and giving
* result of N bit fractN type
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN add_fr1xN_f(fractN, fractN);
#ifdef __cplusplus
}
#endif  //

#else  //    //

#ifdef __cplusplus
extern "C"
{
#endif  //

// Add two N bit numbers and giving result of N bit. The result is saturated to N bits.    PASS!
fractN add_fr1xN(fractN, fractN);

#ifdef __cplusplus
}
#endif  //

#endif  //


/***
* addition of two M bit fractM numbers and giving
* result of M bit fractN type
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM add_fr1xM_f(fractM, fractM);
#ifdef __cplusplus
}
#endif  //

#else  //    //

#ifdef __cplusplus
extern "C"
{
#endif  //

//addition of two M bit fractM numbers and giving result of M bit  fractM type.
fractM add_fr1xM(fractM, fractM);

int8 extract_hi8_fr1xM(fractM v1);
#ifdef __cplusplus
}
#endif  //

#endif  //


/***
* Vector addition of two M bit fract2xN numbers and giving
* result of M bit fract2xN type
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fract2xN add_aa_fr2xN_f(fract2xN, fract2xN);
#ifdef __cplusplus
}
#endif  //

#else  //  

#ifdef __cplusplus
extern "C"
{
#endif  //

// Vector add of two M bit fract2xN numbers, hi+hi, lo+lo and  giving result of fract2xN.
fract2xN add_aa_fr2xN(fract2xN, fract2xN);
#ifdef __cplusplus
}
#endif  //

#endif  //


/***
* Vector subtraction of two M bit fract2xN numbers and giving
* result of M bit fract2xN type
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fract2xN add_ss_fr2xN_f(fract2xN, fract2xN);
#ifdef __cplusplus
}
#endif  //

#else  //  

#ifdef __cplusplus
extern "C"
{
#endif  //

//Vector subtraction of two M bit fract2xN numbers, hi-hi, lo-lo and giving result of fract2xN.
fract2xN add_ss_fr2xN(fract2xN, fract2xN);

#ifdef __cplusplus
}
#endif  //

#endif  //


/***
* Vector add/sub of two M bit fract2xN numbers and giving
* result of M bit fract2xN type
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fract2xN add_as_fr2xN_f(fract2xN, fract2xN);
#ifdef __cplusplus
}
#endif  //

#else  //  

#ifdef __cplusplus
extern "C"
{
#endif  //

//Vector add/sub of two M bit fract2xN numbers, hi+hi, lo-lo and giving result of fract2xN.
fract2xN add_as_fr2xN(fract2xN, fract2xN);

#ifdef __cplusplus
}
#endif  //

#endif  //


/***
* Vector sub/add of two M bit fract2xN numbers and giving
* result of M bit fract2xN type
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fract2xN add_sa_fr2xN_f(fract2xN, fract2xN);
#ifdef __cplusplus
}
#endif  //

#else  //  

#ifdef __cplusplus
extern "C"
{
#endif  //

//Vector sub/add of two M bit fract2xN numbers, hi-hi, lo+lo and giving result of fract2xN.
fract2xN add_sa_fr2xN(fract2xN, fract2xN);

#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Subtraction of two N bit fractN numbers and giving
* result of N bit fractN type
***/

#ifdef FLTPNT               //

#ifdef __cplusplus             //
extern "C"
{
#endif  //
fractN sub_fr1xN_f(fractN, fractN);
#ifdef __cplusplus             //
}
#endif  //             //

#else  //             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //

//Subtract two N bit numbers and giving result of N bit.  The result is saturated to N bits.        @PASS!
fractN sub_fr1xN(fractN, fractN);

#ifdef __cplusplus             //
}
#endif  //             //

#endif  //             //
//=========================================================
#ifdef __cplusplus             //
extern "C"
{
#endif  //

	//Subtract two N bit numbers and giving result of N bit.  The result is saturated to N bits.        @PASS!
	cmplx_t conj_cmplxt(cmplx_t a);

#ifdef __cplusplus             //
}
#endif  //             //



#ifdef __cplusplus             //
extern "C"
{
#endif  //

	//Subtract two N bit numbers and giving result of N bit.  The result is saturated to N bits.        @PASS!
cmplx_t cmlt_cmplxt(cmplx_t x, cmplx_t y);

#ifdef __cplusplus             //
}
#endif  //             //

        //

#ifdef __cplusplus             //
extern "C"
{
#endif  //

	//Subtract two N bit numbers and giving result of N bit.  The result is saturated to N bits.        @PASS!
cmplx_t sub_cmplxt(cmplx_t x, cmplx_t y);
cmplx_t cadd_cmplxt(cmplx_t x, cmplx_t y);

#ifdef __cplusplus             //
}
#endif  //             //



//=========================================================
/***
* Subtraction of two M bit fractM numbers and giving
* result of M bit fractN type
***/

#ifdef FLTPNT             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //
fractM sub_fr1xM_f(fractM, fractM);
#ifdef __cplusplus             //
}
#endif  //             //

#else  //             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //
//Subtraction of two M bit fractM numbers and giving result of M bit  fractM type.
fractM sub_fr1xM(fractM, fractM);
#ifdef __cplusplus             //
}
#endif  //             //

#endif  //             //


/***
* Multiplying two N bit fractN numbers and giving
* result of N bit fractN type
***/

#ifdef FLTPNT             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //             //
fractN mult_fr1xN_f(fractN, fractN);
#ifdef __cplusplus             //
}
#endif  //             //

#else  //             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //             //
//Multiplying two variables of N bit fractN numbers and  giving result of N bit fractN type
fractN mult_fr1xN(fractN, fractN);
cmplx_frM cmlt_frMM(cmplx_frM x, cmplx_frM y);
#ifdef __cplusplus             //
}
#endif  //             //

#endif  //             //


/***
* Multiplying two M bit fractM numbers and giving
* result of M bit fractN type
***/

#ifdef FLTPNT             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //             //
fractM mult_fr1xM_f(fractN, fractN);
#ifdef __cplusplus             //
}
#endif  //             //

#else  //             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //             //
//Multiplying two variables of N bit fractN numbers and  giving result of M bit of fractM type
fractM mult_fr1xM(fractN, fractN);
#ifdef __cplusplus             //
}
#endif  //             //

#endif  //             //


/***
* Multiplying two N bit fractN numbers and giving
* result of N bit with rounded fractN type
***/

#ifdef FLTPNT    
#ifdef __cplusplus             //
extern "C"
{
#endif  //             //

#ifdef __cplusplus             //
}
#endif  //             //
#else
#ifdef __cplusplus             //
extern "C"
{
#endif  //             //
//Multiplying two variables of N bit fractN numbers and giving result of N bit with rounding lower Nbit word
fractN multr_fr1xN(fractN, fractN);
#ifdef __cplusplus             //
}
#endif  //             //

#endif  //             //

/***
* Multiplying one N bit fractN numbers by one M bit fractM numbers
* and giving result of M bit fractM type
***/


#ifdef FLTPNT    
#ifdef __cplusplus             //
extern "C"
{
#endif  //             //

#ifdef __cplusplus             //
}
#endif  //             //
#else
#ifdef __cplusplus             //
extern "C"
{
#endif  //             //
//Multiply N bit fractN and M bit fractM and give result of M bit of fractM type
fractM mlt_frNXfrM_frM(fractN x, fractM y);
#ifdef __cplusplus             //
}
#endif  //             //

#endif  //             //


/***
* Multiplying one M bit fractM numbers by one M bit fractM numbers
* and giving result of M bit fractM type
***/

#ifdef FLTPNT             //

#else  //             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //             //
//Multiply M bit fractM and M bit fractM and give result of M bit of fractM type

#ifdef __cplusplus             //
}
#endif  //             //

#endif  //             //

#ifdef FLTPNT    
#ifdef __cplusplus             //
extern "C"
{
#endif  //             //

#ifdef __cplusplus             //
}
#endif  //             //
#else
#ifdef __cplusplus             //
extern "C"
{
#endif  // 
	fractM mlt_frMXfrM_frM(fractM x, fractM y);
	fractM mlt_frMXfrM_frM2(fractM x, fractM y);
	fractM mlt_frNXfrM_frM2(fractN x, fractM y);

#ifdef __cplusplus             //
}
#endif  //             //

#endif  //             //


/***
* Maximum value of two N bit fractN numbers and giving
* result of N bit fractN type
***/

#ifdef FLTPNT             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //             //
fractN max_fr1xN_f(fractN, fractN);
#ifdef __cplusplus             //
}
#endif  //             //

#else  //             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //             //
//Maximum of two N bit fractN numbers and giving result of N bit  fractN type                           @PASS!
fractN max_fr1xN(fractN, fractN);
#ifdef __cplusplus             //
}
#endif  //             //

#endif  //             //


/***
* Maximum value of fract2xN number and giving
* result of N bit fractN type
***/

#ifdef FLTPNT             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //             //
fract2xN max_fr2xN_f(fract2xN, fract2xN);
#ifdef __cplusplus             //
}
#endif  //             //

#else  //             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //             //
// Vector Maximum of two M bit fract2xN numbers and giving result of M bit  fract2xN type
fract2xN max_fr2xN(fract2xN, fract2xN);
#ifdef __cplusplus             //
}
#endif  //             //

#endif  //             //

/***
* This is for finding the absolute value of given fractN variable
***/

#ifdef FLTPNT             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //             //
fractN abs_fr1xN_f(fractN);
#ifdef __cplusplus             //
}
#endif  //             //

#else  //             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //             //
//Absolute value of N bit fractN number and giving result of N bit fractN type.
fractN abs_fr1xN(fractN);
#ifdef __cplusplus             //
}
#endif  //             //

#endif  //             //


/***
* This is for finding the absolute value of given fract2xN variable
***/

#ifdef FLTPNT             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //             //
fract2xN abs_fr2xN_f(fract2xN);
#ifdef __cplusplus             //
}
#endif  //             //

#else  //             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //             //
//Absolute value of fract2xN number and giving result of fract2xN type.
fract2xN abs_fr2xN(fract2xN);
#ifdef __cplusplus             //
}
#endif  //             //

#endif  //             //


/***
* This is for finding the minimum value of
* given two fractN variables
***/

#ifdef FLTPNT             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //             //
fractN min_fr1xN_f(fractN, fractN);
#ifdef __cplusplus             //
}
#endif  //             //

#else  //             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //             //
//Minimum of two N bit fractN numbers and giving result of N bit fractN type
fractN min_fr1xN(fractN, fractN);
#ifdef __cplusplus             //
}
#endif  //             //

#endif  //             //

/***
* Minimum value of fract2xN number and giving
* result of fract2xN type
***/

#ifdef FLTPNT             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //             //
fract2xN min_fr2xN_f(fract2xN, fract2xN);
#ifdef __cplusplus             //
}
#endif  //             //

#else  //             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //             //
//Vector Minimum of two M bit fract2xN numbers and giving result of M bit  fract2xN type
fract2xN min_fr2xN(fract2xN, fract2xN);
#ifdef __cplusplus             //
}
#endif  //             //

#endif  //             //

/***
* This is for finding the 2's complement(negative) value of
* given fractN variable
***/

#ifdef FLTPNT             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //             //
fractN negate_fr1xN_f(fractN);
#ifdef __cplusplus             //
}
#endif  //             //

#else  //             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //             //
// 2's complement ( Negetive ) value of N bit fractN number and giving result of N bit fractN type
fractN negate_fr1xN(fractN);
#ifdef __cplusplus             //
}
#endif  //             //

#endif  //             //


/***
* This is for finding the 2's complement(negetive)value of
* given fract2xN variable
***/

#ifdef FLTPNT             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //             //
fract2xN negate_fr2xN_f(fract2xN);
#ifdef __cplusplus             //
}
#endif  //             //

#else  //             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //             //
//*2's complement ( Negetive ) value of fract2xN number and giving  result of fract2xN type
fract2xN negate_fr2xN(fract2xN);
#ifdef __cplusplus             //
}
#endif  //             //

#endif  //             //


/***
* This is for shifting left the var1 by var2 times giving
* the result of N bit
***/

#ifdef FLTPNT             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //             //
fractN shl_fr1xN_f(fractN, int);
#ifdef __cplusplus             //
}
#endif  //             //

#else  //             //

#ifdef __cplusplus             //
extern "C"
{
#endif  //
//Left shifting the variable1 of N bit fractN by varible2 times and giving result of N bit fractN type
fractN shl_fr1xN(fractN, int);
#ifdef __cplusplus
}
#endif  //

#endif  //


/***
* This is for shifting right the var1 by var2 times giving
* the result of N bit
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN shr_fr1xN_f(fractN, int);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
//Right shifting the variable1 of N bit fractN by varible2 times and giving result of N bit fractN type
fractN shr_fr1xN(fractN, int);
#ifdef __cplusplus
}
#endif  //

#endif  //

//add by dengruinan@2010-11-08,CRID:BBAlg_Inc00000054
#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
//fractN shr_fr1xN_f(fractN, int);
#ifdef __cplusplus
}
#endif  //

#else  //
#ifdef __cplusplus
extern "C"
{
#endif  //
//Right shifting the variable1 of N bit fractN by varible2 times with rounding and giving result of N bit fractN type
fractN shr_fr1xN_Round(fractN, int);
#ifdef __cplusplus
}
#endif  //

#endif  //
//add by dengruinan@2010-11-08,CRID:BBAlg_Inc00000054

/***
* Multiplying two N bit fractN numbers and giving
* result of M bit fractM type
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
	//fractN shr_fr1xN_f(fractN, int);
#ifdef __cplusplus
}
#endif  //
fractM mult_fr1xM_f(fractN, fractN);
#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
//Multiplying two variables of N bit fractN numbers and giving result of M bit of fractM type
fractM mult_fr1xM(fractN, fractN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* MAC of two N bit fractN numbers
* return M bit fractM numbers
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM mac_frN_M_f(fractM x, fractN a, fractN b);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
//Multiply and accumulate of two N bit fractN numbers and giving result of M bit of fractM type
fractM mac_frN_M(fractM, fractN, fractN);
#ifdef __cplusplus
}
#endif  //

#endif  //


/***
**  MAC40 operation  **
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
void mac_frN_40_f(fract40 *acc, fractN x, fractN y);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
//Multiply and accumulate of two N bit fractN numbers and  giving result of M bit of fract40 type
void mac_frN_40(fract40*, fractN, fractN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
**  Shr40 operation  **
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
void shr_fr1x40_f(fract40* acc, int32 scale);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
//Right Shifting accumulate of fract40 type by int value and giving result of 40 bit of fract40 type
void shr_fr1x40(fract40*, int32);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
**  Shl40 operation **
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
void shl_fr1x40_f(fract40* acc, int32 scale);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
//Left Shifting accumulate of fract40 type by int value and giving result of 40 bit of fract40 type
void shl_fr1x40(fract40*, int32);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
**  Ashift40 operation **
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
void ashift_fr1x40_f(fract40* acc, int16 scale);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
//Left Shifting or rigth shift the accumulator depending on the sign of the shift value
void ashift_fr1x40(fract40* acc, int16 scale);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* addition between one M bit fractM numbers and one
* 40 bit fract40 number giving result of 40 bit fract40 type
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
void add_frM_40_f(fract40* acc, fractM x);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
//Adds a fractM to an accumulator ( fract40 ). The result is in the fract40
void add_frM_40(fract40* acc, fractM x);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* addition of two 40 bit fract40 numbers giving
* result of 40 bit fract40 type
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
void add_fr40_40_f(fract40* acc, fract40 acc2);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
void add_fr40_40(fract40* acc, fract40 acc2);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
**  Norm fract40 operations  **
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
int32 norm_fr1x40_f(fract40 acc);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
int32 norm_fr1x40(fract40 acc);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
**  signbit fract40 operations  **
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
int32 signbit_fr1x40_f(fract40);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
int32 signbit_fr1x40(fract40);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
**  return the double type of fract40 number
**  Q(40,40-M) for fix point input
**  double for double point input
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
double read_fr40_f(fract40 acc);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
double read_fr40(fract40 acc);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
**  Convert fract40 input to fractM output
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM fract40_to_fractM_f(fract40  acc);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM fract40_to_fractM(fract40  acc);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
**  Convert fractN input to fract40 output
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
void fractN_to_fract40_f(fractN v, fract40  *acc);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
void fractN_to_fract40(fractN v, fract40  *acc);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
**  Convert fract40 input to fractN output
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN fract40_to_fractN_f(fract40);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN fract40_to_fractN(fract40);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
**  Convert fractM input to fract40 output
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
void fractM_to_fract40_f(fractM v, fract40  *acc);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
void fractM_to_fract40(fractM v, fract40  *acc);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
**  complex fract40 operations  **
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
void cmac_fr40_f(fract40 *acc1, fract40 *acc2, cmplx_frN v1, cmplx_frN v2);
void conjmac_fr40_f(fract40 *acc1, fract40 *acc2, cmplx_frN v1, cmplx_frN v2);
void conjmlt_fr40_f(fract40 *acc1, fract40 *acc2, cmplx_frN v1, cmplx_frN v2);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
void cmac_fr40(fract40 *acc1, fract40 *acc2, cmplx_frN v1, cmplx_frN v2);
void conjmac_fr40(fract40 *acc1, fract40 *acc2, cmplx_frN v1, cmplx_frN v2);
void conjmlt_fr40(fract40 *acc1, fract40 *acc2, cmplx_frN v1, cmplx_frN v2);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
**  multing of two fractN number
**  giving result of fract40 type
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
void mlt_frN_40_f(fract40*, fractN, fractN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
void mlt_frN_40(fract40*, fractN, fractN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Crosscorrelation of two complex vectors and scaling operation
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN ccrosscorr_ashift_cfrN_f(cmplx_frN* x, cmplx_frN* y, int32 len, int16 shift);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN ccrosscorr_ashift_cfrN(cmplx_frN* x, cmplx_frN* y, int32 len, int16 shift);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
** Convolution of two complex vectors and scaling operation **
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN cconv_ashift_cfrN_f(cmplx_frN* x, cmplx_frN* y, int32 len, int16 shift);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN cconv_ashift_cfrN(cmplx_frN* x, cmplx_frN* y, int32 len, int16 shift);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
** Conjugate multiplication of two complex numbers and scaling operation **
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN conjmlt_ashift_cfrN_f(cmplx_frN x, cmplx_frN y, int16 shift);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN conjmlt_ashift_cfrN(cmplx_frN x, cmplx_frN y, int16 shift);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
** Complex square of one complex numbers and scaling operation **
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM csqu_ashift_frM_f(cmplx_frN x, int16 shift);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM csqu_ashift_frM(cmplx_frN x, int16 shift);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
** Vector MACM operation  **
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM vmac_frN_M_f(fractN*, fractN*, int32, int32);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM vmac_frN_M(fractN*, fractN*, int32, int32);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
** Vector MAC40 operation   **
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM vmac_frN_40_f(fractN*, fractN*, int32, int32);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM vmac_frN_40(fractN*, fractN*, int32, int32);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
** Vector cmls40 operation **
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN vmac_cmls_40_f(cmplx_frN*, fractN*, int32, int32);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN vmac_cmls_40(cmplx_frN*, fractN*, int32, int32);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
** Vector csqu40 operation **
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM vmac_csqu_40_f(cmplx_frN*, int32, int32);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM vmac_csqu_40(cmplx_frN*, int32, int32);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* This is for finding maximum of given two fractM varibles and
* giving output of M bit fractM type
***/

#ifdef FLTPNT
#ifdef __cplusplus
extern "C"
{
#endif  //
fractM max_fr1xM_f(fractM, fractM);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM max_fr1xM(fractM, fractM);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* This is for finding the absolute value of given fractM variable
***/

#ifdef FLTPNT
#ifdef __cplusplus
extern "C"
{
#endif  //
fractM abs_fr1xM_f(fractM);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM abs_fr1xM(fractM);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* This is for finding the minimum value of given two fractM variables
***/

#ifdef FLTPNT
#ifdef __cplusplus
extern "C"
{
#endif  //
fractM min_fr1xM_f(fractM, fractM);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM min_fr1xM(fractM, fractM);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* This is for finding the 2's complement(negetive)value of
* given fractM variable
***/

#ifdef FLTPNT
#ifdef __cplusplus
extern "C"
{
#endif  //
fractM negate_fr1xM_f(fractM);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM negate_fr1xM(fractM);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* This is for shifting left the var1 of M  bit fractM type by var2 times
***/

#ifdef FLTPNT
#ifdef __cplusplus
extern "C"
{
#endif  //
fractM shl_fr1xM_f(fractM, int);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM shl_fr1xM(fractM, int);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* This is for shifting right the var1 of M bit fractM type by var2 times, giving
* the result of M bit
***/

#ifdef FLTPNT
#ifdef __cplusplus
extern "C"
{
#endif  //
fractM shr_fr1xM_f(fractM, int);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM shr_fr1xM(fractM, int);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* this is for saturating the  Mbit value and returning result of Nbit
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN sat_fr1xN_f(fractM);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN sat_fr1xN(fractM);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* this is for saturating the  Nbit value of fractN type and returning result of Nbit
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN satN_f(fractN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN satN(fractN);
#ifdef __cplusplus
}
#endif  //

#endif  //

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN satM_f(fractM);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM satM(int64);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
** Bit setting for biased rounding  **
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
void   set_rnd_mode_biased_f();
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
void   set_rnd_mode_biased();
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
** Bit setting for unbiased rounding  **
***/

#ifdef INTRINSICS

#ifdef __cplusplus
extern "C"
{
#endif  //
void   set_rnd_mode_unbiased_f();
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
void   set_rnd_mode_unbiased();
void set_rnd_mode_floor();

#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* This is for rounding the var1 of Mbit, giving the result of Nbit
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN round_fr1xM_f(fractM);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN round_fr1xM(fractM);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* This is for get the extend sign bit numbers,
* giving the result of int16
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
int16 norm_fr1xN_f(fractN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
int16 norm_fr1xN(fractN);
#ifdef __cplusplus
}
#endif  //

#endif  //

int16 norm_width_bit(int64  in1, int16 with_len);
/***
* This is for get the extend sign bit numbers,
* giving the result of int16
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
	inline int16 norm_fr1xM(fractM var1)
	{
		return ((int16) __builtin_norm_fr1xM(var1));
	};
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
int16 norm_fr1xM(fractM);
int16 norm_fr1x64(int64);
#ifdef __cplusplus
}
#endif  //

#endif  //


/***
*
* The following functions have included as an intrinsics (builtin)
*
* These are the functions which are included after correlating with
* the web page, blackfin_coding
*
***/

/***
* Extracting the higher value of fractM number
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //

#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN extract_hi_fr1xM(fractM);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Extracting the higher value of fract2xN number
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN extract_hi_fr2xN_f(fract2xN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN extract_hi_fr2xN(fract2xN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Extracting the lower value of fractM number
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
	fractN extract_hi_fr2xN_f(fract2xN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN extract_lo_fr1xM(fractM);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Extracting the lower value of fract2xN number
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN extract_lo_fr2xN_f(fract2xN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN extract_lo_fr2xN(fract2xN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Composing the two fractN values and giving
* result of fractM
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //

#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM compose_fr1xM(fractN, fractN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Composing the two fractN values and giving
* result of fract2xN
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fract2xN compose_fr2xN_f(fractN, fractN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fract2xN compose_fr2xN(fractN, fractN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Extracting the imaginery value of cmplx fract number
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN extract_im_f(cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN extract_im(cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Extracting the real value of cmplx fract number
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN extract_re_f(cmplx_frN a);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN extract_re(cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* compising the cmplx fract number
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN compose_cfrN_f(fractN, fractN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN compose_cfrN(fractN, fractN);
#ifdef __cplusplus
}
#endif  //

#endif  //


#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frM compose_cfrM(fractM, fractM);
#ifdef __cplusplus
}
#endif  //


/***
* Sum of hi, lo of the fract2xN number
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN sum_fr2xN_f(fract2xN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN sum_fr2xN(fract2xN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Difference of hi, lo of the fract2xN number
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN dif_hl_fr2xN_f(fract2xN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN dif_hl_fr2xN(fract2xN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Difference of lo, hi of the fract2xN number
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN dif_lh_fr2xN_f(fract2xN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN dif_lh_fr2xN(fract2xN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Interger Sum of lo, hi of the fract2xN number
***/

#ifdef FLTPNT

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN sum_i2xN(fract2xN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
*
* The following functions have included as an intrinsics (builtin)
* in the recent version.
*
* These are the functions which are only works on frio environment
*
* Their prototypes are in the deffrio.h file, since they were misc
* frio-only builtins that didn't fit anywhere else  //
*
***/

/***
* Counting number of ones in a given input
***/

#ifdef FLTPNT
#ifdef __cplusplus
extern "C"
{
#endif  //
fractN ones_f(fractM);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN ones(fractM);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Expadj of two inputs
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
int16 expadj1xN_f(fractN, int16);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
int16 expadj1xN(fractN, int16);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* ExpadjM of two inputs
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
	int16 expadj1xN_f(fractN, int16);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
int16 expadj1xM(fractM, int16);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Expadj2xN of two inputs
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
int16 expadj2xN_f(cmplx_frN in1, int16);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
int16 expadj2xN(fractM, int16);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
*  lvitmax1xN function
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
void lvitmax1xN_f(fract2xN, int32, fractN*, int32*);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
void lvitmax1xN(fract2xN, int32, fractN*, int32*);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
*  rvitmax1xN function
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
void rvitmax1xN_f(fract2xN, int32, fractN*, int32*);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
void rvitmax1xN(fract2xN, int32, fractN*, int32*);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
*  lvitmax2xN function
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
void lvitmax2xN_f(fract2xN, fract2xN, int32, fract2xN*, int32*);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
void lvitmax2xN(fract2xN, fract2xN, int32, fract2xN*, int32*);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
*  rvitmax2xN function
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
void rvitmax2xN_f(fract2xN, fract2xN, int32, fract2xN*, int32*);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
void rvitmax2xN(fract2xN, fract2xN, int32, fract2xN*, int32*);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
** Functions for bit interleaving  **
***/

/***
* Multiplexing through right
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //

#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
void bitmux_shr(fractM*, fractM*, fractM*, fractM*);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Multiplexing through left
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //

#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
void bitmux_shl(fractM*, fractM*, fractM*, fractM*);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
*
* The following functions for complex numbers, some do not have an intrinsic
* (built_in)version. They are implemented in Frio assembly.
*
* It is expected that in a later revision of the compiler
* they will be implemented as intrinsics.
*
***/

/***
* Cadd_frN function
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN cadd_frN_f(cmplx_frN _a, cmplx_frN _b);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN cadd_frN(cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Cadd_frN function
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frM cadd_frM_f(cmplx_frM, cmplx_frM);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frM cadd_frM(cmplx_frM, cmplx_frM);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Csub_frN function
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN csub_frN_f(cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN csub_frN(cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Csub_frM function
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frM csub_frM_f(cmplx_frM, cmplx_frM);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frM csub_frM(cmplx_frM, cmplx_frM);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Cmlt_frN function
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN  cmlt_frN_f(cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN  cmlt_frN(cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#endif  //

///////////////////////// Add by wangnaibo 2006-09-05
/***
* Cmlt_frN2 function
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //

#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN  cmlt_frN2(cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#endif  //
///////////////////////// Add end
/***
* Cmlt_frM function
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frM cmlt_frM_f(cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frM cmlt_frM(cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Complex multiply and accumulator function cmac_frN
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN cmac_frN_f(cmplx_frN, cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN cmac_frN(cmplx_frN, cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Complex multiply and accumulator function cmac_frM
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frM cmac_frM_f(cmplx_frM, cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frM cmac_frM(cmplx_frM, cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#endif  //


/***
* Complex multiply and subtractor function
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN cmsu_frN_f(cmplx_frN, cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN cmsu_frN(cmplx_frN, cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
*
* These functions has no built in functions, they will be
* implemented as intrinsics in the coming versions.
*
***/


/***
* complex conjugate of a given variable
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN  conj_frN_f(cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN  conj_frN(cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* complex conjugate multiplication i.e _a * (_b*) of a given variables
* giving result of cmplx_frN type
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN  conjmlt_frN_f(cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN  conjmlt_frN(cmplx_frN, cmplx_frN);
cmplx_frN  conjmlt_frN2(cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* complex conjugate multiplication i.e _a * (_b*) of a given variables
* giving result of cmplx_frM type
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frM  conjmlt_frM_f(cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frM  conjmlt_frM(cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Complex conjugate multiply and accumulator function
* giving result of cmplx_frN type
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN conjmac_frN_f(cmplx_frN, cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN conjmac_frN(cmplx_frN, cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Complex conjugate multiply and accumulator function
* giving result of cmplx_frM type
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frM conjmac_frM_f(cmplx_frM, cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frM conjmac_frM(cmplx_frM, cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Complex left shift of real and imaginary part by given bits with saturation
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN cshl_frN_f(cmplx_frN, int);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN cshl_frN(cmplx_frN, int);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Complex left shift of real and imaginary part by given bits with saturation
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frM cshl_frM_f(cmplx_frM, int);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frM cshl_frM(cmplx_frM, int);
#ifdef __cplusplus
}
#endif  //

#endif  //


/***
* Complex right shift of real and imaginary part by given bits
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN cshr_frN_f(cmplx_frN, int);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN cshr_frN(cmplx_frN, int);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Complex right shift of real and imaginary part by given bits
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frM cshr_frM_f(cmplx_frM, int);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frM cshr_frM(cmplx_frM, int);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Complex exponent adjust of real and imaginery values with gigen exp value
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
int16 cexpadj_frN_f(cmplx_frN in1, int16);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
int16 cexpadj_frN(cmplx_frN, int16);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***** add by qiyingjie @20131115 Enh00000321 BEGIN****/
#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
int16 cexpadj_frM_f(cmplx_frM in1, int16);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
int16 cexpadj_frM(cmplx_frM, int16);
#ifdef __cplusplus
}
#endif  //

#endif  //
/***** add by qiyingjie @20131115 Enh00000321 END****/


/***
* vector negate of complex variable
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN cnegate_frN_f(cmplx_frN in1);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN cnegate_frN(cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#endif  //

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frM cnegate_frM_f(cmplx_frM in1);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frM cnegate_frM(cmplx_frM);
#ifdef __cplusplus
}
#endif  //

#endif  //


/***
* Complex square function with N bit return
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN csqu_frN_f(cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN csqu_frN(cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Complex square function with M bit return
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM csqu_frM_f(cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM csqu_frM(cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Complex distance function with Nbit return
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN cdst_frN_f(cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN cdst_frN(cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Complex distance function with Mbit return
***/

#ifdef FLTPNT

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM cdst_frM(cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Complex multiply with fract value
* giving return of cmplx_frN type
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN cmls_frN_f(cmplx_frN, fractN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN cmls_frN(cmplx_frN, fractN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Complex multiply with fract value
* giving return of cmplx_frM type
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frM cmls_frM_f(cmplx_frN, fractN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frM cmls_frM(cmplx_frN, fractN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Complex integer multiply with fract value
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
	cmplx_frM cmls_frM_f(cmplx_frN, fractN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN cmls_i2xN(cmplx_frN, fractN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Complex integer multiply
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN cmlt_iN_f(cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN cmlt_iN(cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
*
* The following functions do not have an intrinsic (builtin)
* version. They are implemented in Frio assembly.
*
***/

/***
* signed integer Multiplication of two 16 bit numbers and giving
* result of 16 bit
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
int16 mult_i1xN_f(int16, int16);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
int16 mult_i1xN(int16, int16);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* DIVS_16 implementation
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN divs_fr1xN_f(fractN, fractN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN divs_fr1xN(fractN, fractN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* DIVS_M implementation
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM divs_fr1xM_f(fractM, fractM);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM divs_fr1xM(fractM, fractM);
#ifdef __cplusplus
}
#endif  //

#endif  //

// added by yanwei, 2011-02-22

/***
* DIVS_M implementation(24 bit divs), the result is Q(24, 9)
***/

// end
#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //

#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM divs_fr1xM_TH(fractM nem, fractM dnem);
#ifdef __cplusplus
}
#endif  //

#endif  //
/***
* DIVS_16 implementation
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN divs_fr1xN_f(fractN, fractN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN divs_i1xN(fractN, fractN, uint8);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* DIVS_M implementation
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM divs_fr1xM_f(fractM, fractM);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractM divs_i1xM(fractM, fractM, uint8);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* division of complex nuber with real value
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN cdivr_frN_f(cmplx_frN, fractN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN cdivr_frN(cmplx_frN, fractN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
** complex division **
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN cdiv_frN_f(cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
cmplx_frN cdiv_frN(cmplx_frN, cmplx_frN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
** SQRT_fr1xN implementation
** input is Q(N,1) type
** output is Q(N,8) type
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN sqrt_fr1xN_f(fractN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN sqrt_fr1xN(fractN);
#ifdef __cplusplus
}
#endif  //

#endif  //

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN sqrt_fr1xN_f(fractN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
uint16 ssqrt_TH(uint32);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
** ISQRT implementation **
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
uint32 isqrt_f(uint32);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
uint32 isqrt(uint32);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
** Finding the COS of given radians input **
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN cos_frN_rad_f(fractN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN cos_frN_rad(fractN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
** Finding the COS(x*pi/2) of given input x **
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN cos_frN_f(fractN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN cos_frN(fractN);
#ifdef __cplusplus
}
#endif  //

#endif  //


/***
** Finding the SIN(x*pi/2) of given input x **
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN sin_frN_f(fractN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN sin_frN(fractN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
**for a input fractN type parameter x(Q(N,1)),
**give the result of 1/sqrt(x)(Q(N,ceil(N/2)))
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN rsqrt_frN_f(fractN);
#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
fractN rsqrt_frN(fractN);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
**below codes is for L+M bits accumulator
***/

#ifdef FLTPNT

#ifdef __cplusplus
extern "C"
{
#endif  //

#ifdef __cplusplus
}
#endif  //

#else  //

#ifdef __cplusplus
extern "C"
{
#endif  //
void set_L_Length(int n);
void mac_frN_LXM(fractLXM *acc, fractN x, fractN y);
void shr_frLXM(fractLXM *acc, int32 scale);
void shl_frLXM(fractLXM *acc, int32 scale);
double read_frLXM(fractLXM acc);
int32 signbit_frLXM(fractLXM acc);
fractM vmac_frN_LXM(fractN *vec1, fractN *vec2, int32 len, int32 scale);
void add_frM_LXM(fractLXM *acc, fractM x);
void add_frLXM_LXM(fractLXM *acc, fractLXM acc2);
void mlt_frN_LXM(fractLXM *acc, fractN x, fractN y);
void conjmac_frLXM(fractLXM *acc1, fractLXM *acc2, cmplx_frN v1, cmplx_frN v2);
void cmac_frLXM(fractLXM *acc1, fractLXM *acc2, cmplx_frN v1, cmplx_frN v2);
void conjmlt_frLXM(fractLXM *acc1, fractLXM *acc2, cmplx_frN v1, cmplx_frN v2);
unsigned carry_out(int a, int b);
#ifdef __cplusplus
}
#endif  //

#endif  //

/***
* Below code is added to get the capabilities of math.h file
***/
/*
#ifdef __cplusplus
extern "C"
{
#endif  //
    double floor (double _x);
    double pow (double _x, double _exp);
    double frexp (double _x, int * _exp);
    double modf (double _x, double * _integral);
    double sqrt (double _x);
    double exp (double _x);
    double ceil (double _x);
    double log (double _x);
#ifdef __cplusplus
}
#endif  //

#ifdef __cplusplus
extern "C"
{
#endif  //
    double cos(double);
    double sin(double);
#ifdef __cplusplus
}
#endif  //
*/

/***
* Below code is added to make bit produce
***/
#ifdef __cplusplus
extern "C"
{
#endif  //
unsigned int bit_reverse(unsigned int n);
int count_ones(int n);
#ifdef __cplusplus
}
#endif  //
/***
* Below code is added to read/write register
***/
#ifdef __cplusplus
extern "C"
{
#endif  //
int32 memoryget(uint32 Reg_Name, uint8 High_N, uint8 Low_N);

uint32 unsign_memoryget(uint32 Reg_Name, uint8 High_N, uint8 Low_N);

void writememory(uint32 *OutputData, int32 InputData, uint8 High_N, uint8 Low_N);

#ifdef __cplusplus
}
#endif  //


/***
* Below code is added to convert complex_frN to complex_frM
***/
#ifdef __cplusplus
extern "C"
{
#endif  //

cmplx_frM cmplx_frN2frM(cmplx_frN v);
cmplx_frN cmplx_frM2frN(cmplx_frM v);

fractN real_t_2_fractN(real_t v, real_t scale = 32768.0, real_t max_v = 32767.0, real_t min_v = -32768.0);

fractM real_t_2_fractM(real_t v, real_t scale = 2147483648.0, real_t max_v = 2147483647.0, real_t min_v = -2147483648.0);

real_t fractN_2_real_t(fractN v, real_t scale = 32768.0);

real_t fractM_2_real_t(fractM v, real_t scale = 2147483648.0);

cmplx_frN cmplx_t_2_cmplx_frN(cmplx_t v, real_t scale = 32768.0, real_t max_v = 32767.0, real_t min_v = -32768.0, int round_flag = 0);

cmplx_t cmplx_frN_2_cmplx_t(cmplx_frN v, real_t scale = 32768.0);

cmplx_frM cmplx_t_2_cmplx_frM(cmplx_t v, real_t scale = 2147483648.0, real_t max_v = 2147483647.0, real_t min_v = -2147483648.0);

//cmplx_t cmplx_frM_2_cmplx_t(cmplx_frN v, real_t scale = 2147483648.0);
cmplx_t cmplx_frM_2_cmplx_t(cmplx_frM v, real_t scale = 2147483648.0);

void write_file_fpga(char filename[100], cmplx_frN *data, char way,int len, int bitlen);

#ifdef __cplusplus
}
#endif  //
cmplx_frM cmlt_frNM(cmplx_frN x, cmplx_frM y);
cmplx_frM conj_frM(cmplx_frM a);

/*
* This set of macros maps the library functions used in
* user code into two sets: (a) fixed point, and (b) doubleing
* point.
* The naming convention uses the same base name as the
* fixed point functions, and for doubleing point it appends
* a "_f". The macro which is user visible capitalizes
* the first letter of the function.
*
*/
/* Floating Point begin here
*
*/
#ifdef FLTPNT
#define Add_fr1xN                       add_fr1xN_f
#define Add_fr1xM                       add_fr1xM_f
#define Add_aa_fr2xN                    add_aa_fr2xN_f
#define Add_ss_fr2xN                    add_ss_fr2xN_f
#define Add_as_fr2xN                    add_as_fr2xN_f
#define Add_sa_fr2xN                    add_sa_fr2xN_f
#define Sub_fr1xN                       sub_fr1xN_f
#define Sub_fr1xM                       sub_fr1xM_f
//#define Sub_fr2xN                     sub_fr2xN_f
#define Mult_fr1xN                      mult_fr1xN_f
#define Mult_fr1xM                      mult_fr1xM_f
#define Mlt_frNXfrM_frM                 mlt_frNXfrM_frM_f
#define Mlt_frMXfrM_frM                 mlt_frMXfrM_frM_f
#define Multr_fr1xN                     mult_fr1xN_f
#define Mult_i1xN                       mult_i1xN_f
#define Abs_fr1xN                       abs_fr1xN_f
#define Abs_fr2xN                       abs_fr2xN_f
#define Min_fr1xN                       min_fr1xN_f
#define Min_fr2xN                       min_fr2xN_f
#define Max_fr1xN                       max_fr1xN_f
#define Max_fr2xN                       max_fr2xN_f
#define Negate_fr1xN                    negate_fr1xN_f
#define Shl_fr1xN                       shl_fr1xN_f
#define Shr_fr1xN                       shr_fr1xN_f

#define Add_frM_40                      add_frM_40_f
#define Add_fr40_40                     add_fr40_40_f
#define Ashift_fr1x40                   ashift_fr1x40_f
#define Mac_frN_M                       mac_frN_M_f
#define Mac_frN_40                      mac_frN_40_f
#define Mlt_frN_40                      mlt_frN_40_f
#define Vmac_frN_M                      vmac_frN_M_f
#define Vmac_frN_40                     vmac_frN_40_f
#define Vmac_csqu_40                    vmac_csqu_40_f
#define Vmac_cmls_40                    vmac_cmls_40_f
#define Ccrosscorr_ashift_cfrN          ccrosscorr_ashift_cfrN_f
#define Cconv_ashift_cfrN               cconv_ashift_cfrN_f
#define Abs_fr1xM                       abs_fr1xN_f
#define Min_fr1xM                       min_fr1xN_f
#define Max_fr1xM                       max_fr1xN_f
#define Negate_fr1xM                    negate_fr1xN_f
#define Shl_fr1xM                       shl_fr1xN_f
#define Shr_fr1xM                       shr_fr1xN_f
#define Shr_fr1x40                      shr_fr1x40_f
#define Shl_fr1x40                      shl_fr1x40_f
#define Sat_fr1xN                       sat_fr1xN_f
#define Set_rnd_mode_biased             set_rnd_mode_biased_f
#define Set_rnd_mode_unbiased           set_rnd_mode_unbiased_f
#define Round_fr1xM                     sat_fr1xN_f
#define Norm_fr1xN                      norm_fr1xN_f
#define Norm_fr1xM                      norm_fr1xN_f
#define Norm_fr1x40                     norm_fr1x40_f

#define Sum_fr2xN                       sum_fr2xN_f
#define Dif_lh_fr2xN                    dif_lh_fr2xN_f
#define Dif_hl_fr2xN                    dif_hl_fr2xN_f
#define FractM_to_fract40               fractM_to_fract40_f
#define FractN_to_fract40               fractN_to_fract40_f
#define Fract40_to_fractM               fract40_to_fractM_f
#define Fract40_to_fractN               fract40_to_fractM_f
#define Sum_i2xN                        sum_i2xN_f
#define Extract_hi_fr1xM                extract_hi_fr1xM_f
#define Extract_hi_fr2xN                extract_hi_fr2xN_f
#define Extract_im                      extract_im_f
#define Extract_lo_fr1xM                extract_lo_fr1xM_f
#define Extract_lo_fr2xN                extract_lo_fr2xN_f
#define Extract_re                      extract_re_f
#define Compose_fr1xM                   compose_fr1xM_f
#define Compose_fr2xN                   compose_fr2xN_f
#define Compose_cfrN                    compose_cfrN_f
#define Read_fr40                       read_fr40_f


#define Ones                            ones_f
#define Expadj1xN                       expadj1xN_f
#define Expadj1xM                       expadj1xN_f
#define Expadj2xN                       expadj2xN_f
#define Lvitmax1xN                      lvitmax1xN_f
#define Rvitmax1xN                      rvitmax1xN_f
#define Lvitmax2xN                      lvitmax2xN_f
#define Rvitmax2xN                      rvitmax2xN_f
#define Bitmux_shr                      bitmux_shr_f
#define Bitmux_shl                      bitmux_shl_f

#define Cadd_frN                        cadd_frN_f
#define Cadd_frM                        cadd_frM_f
#define Csub_frN                        csub_frN_f
#define Csub_frM                        csub_frM_f
#define Cmlt_frM                        cmlt_frM_f
#define Cmlt_frN                        cmlt_frN_f
///////////////////////// Add by wangnaibo 2006-09-05
#define Cmlt_frN2                       cmlt_frN_f
///////////////////////// Add end
#define Cmls_frM                        cmls_frM_f
#define Conjmlt_frN                     conjmlt_frN_f
#define Conjmlt_frM                     conjmlt_frM_f
#define Conjmlt_fr40                    conjmlt_fr40_f
#define Conjmlt_ashift_cfrN             conjmlt_ashift_cfrN_f
#define Conj_frN                        conj_frN_f
#define Cmac_frN                        cmac_frN_f
#define Cmac_frM                        cmac_frM_f
#define Cmac_fr40                       cmac_fr40_f
#define Cmsu_frN                        cmsu_frN_f
#define Csqu_frN                        csqu_frN_f
#define Csqu_frM                        csqu_frM_f
#define Csqu_ashift_frM                 csqu_ashift_frM_f
#define Cdst_frN                        cdst_frN_f
#define Cdst_frM                        cdst_frM_f
#define Conjmac_frN                     conjmac_frN_f
#define Conjmac_frM                     conjmac_frM_f
#define Conjmac_fr40                    conjmac_fr40_f

#define Cshl_frN                        cshl_frN_f
#define Cshr_frN                        cshr_frN_f
#define Cshr_frM                        cshr_frM_f
#define Cexpadj_frN                     cexpadj_frN_f
#define Cexpadj_frM                     cexpadj_frM_f //add by qiyingjie @20131115 Enh00000321
#define Cnegate_frN                     cnegate_frN_f
#define Cmls_frN                        cmls_frN_f
#define Cmls_iN                         cmls_frN_f
#define Cmlt_iN                         cmlt_frN_f
#define Cmlt_frM                        cmlt_frM_f
#define Cdiv_frN                        cdiv_frN_f
#define Cdivr_frN                       cdivr_frN_f

#define Divs_fr1xN                      divs_fr1xN_f
#define Divs_fr1xM                      divs_fr1xM_f
#define Sqrt_fr1xN                      sqrt_fr1xN_f
#define Isqrt                           isqrt_f
//#define Rsqrt_frN                     rsqrt_frN_f
#define Cos_frN_rad                     cos_frN_rad_f
#define Cos_frN                         cos_frN_f
#define Sin_frN                         sin_frN_f
#define Set_bit_width                   set_bit_width_f
#define BitWidth                        bitWidth_f


/* Fixed Point begin here
*
*/
#else  //
#define Add_fr1xN                       add_fr1xN
#define Add_fr1xM                       add_fr1xM
#define Add_aa_fr2xN                    add_aa_fr2xN
#define Add_ss_fr2xN                    add_ss_fr2xN
#define Add_as_fr2xN                    add_as_fr2xN
#define Add_sa_fr2xN                    add_sa_fr2xN
#define Sub_fr1xN                       sub_fr1xN
#define Sub_fr1xM                       sub_fr1xM
#define Mult_fr1xN                      mult_fr1xN
#define Mult_fr1xM                      mult_fr1xM
#define Mlt_frNXfrM_frM                 mlt_frNXfrM_frM
#define Mlt_frMXfrM_frM                 mlt_frMXfrM_frM
#define Multr_fr1xN                     multr_fr1xN
#define Mult_i1xN                       mult_i1xN
#define Abs_fr1xN                       abs_fr1xN
#define Abs_fr2xN                       abs_fr2xN
#define Min_fr1xN                       min_fr1xN
#define Min_fr2xN                       min_fr2xN
#define Max_fr1xN                       max_fr1xN
#define Max_fr2xN                       max_fr2xN
#define Negate_fr1xN                    negate_fr1xN
#define Shl_fr1xN                       shl_fr1xN
#define Shr_fr1xN                       shr_fr1xN

#define Add_frM_40                      add_frM_40
#define Add_fr40_40                     add_fr40_40
#define Ashift_fr1x40                   ashift_fr1x40
#define Mac_frN_M                       mac_frN_M
#define Mac_frN_40                      mac_frN_40
#define Mlt_frN_40                      mlt_frN_40
#define Vmac_frN_M                      vmac_frN_M
#define Vmac_frN_40                     vmac_frN_40
#define Vmac_csqu_40                    vmac_csqu_40
#define Vmac_cmls_40                    vmac_cmls_40
#define Ccrosscorr_ashift_cfrN          ccrosscorr_ashift_cfrN
#define Cconv_ashift_cfrN               cconv_ashift_cfrN
#define Abs_fr1xM                       abs_fr1xM
#define Min_fr1xM                       min_fr1xM
#define Max_fr1xM                       max_fr1xM
#define Negate_fr1xM                    negate_fr1xM
#define Shl_fr1xM                       shl_fr1xM
#define Shr_fr1xM                       shr_fr1xM
#define Shr_fr1x40                      shr_fr1x40
#define Shl_fr1x40                      shl_fr1x40
#define Sat_fr1xN                       sat_fr1xN
#define Set_rnd_mode_biased             set_rnd_mode_biased
#define Set_rnd_mode_unbiased           set_rnd_mode_unbiased
#define Round_fr1xM                     round_fr1xM
#define Norm_fr1xN                      norm_fr1xN
#define Norm_fr1xM                      norm_fr1xM
#define Norm_fr1x40                     norm_fr1x40

#define Sum_fr2xN                       sum_fr2xN
#define Dif_lh_fr2xN                    dif_lh_fr2xN
#define Dif_hl_fr2xN                    dif_hl_fr2xN
#define FractM_to_fract40               fractM_to_fract40
#define FractN_to_fract40               fractN_to_fract40
#define Fract40_to_fractM               fract40_to_fractM
#define Fract40_to_fractN               fract40_to_fractN
#define Sum_i2xN                        sum_i2xN
#define Extract_hi_fr1xM                extract_hi_fr1xM
#define Extract_hi_fr2xN                extract_hi_fr2xN
#define Extract_im                      extract_im
#define Extract_lo_fr1xM                extract_lo_fr1xM
#define Extract_lo_fr2xN                extract_lo_fr2xN
#define Extract_re                      extract_re
#define Compose_fr1xM                   compose_fr1xM
#define Compose_fr2xN                   compose_fr2xN
#define Compose_cfrN                    compose_cfrN
#define Read_fr40                       read_fr40

#define Ones                            ones
#define Expadj1xN                       expadj1xN
#define Expadj1xM                       expadj1xM
#define Expadj2xN                       expadj2xN
#define Sum_i2xN                        sum_i2xN
#define Lvitmax1xN                      lvitmax1xN
#define Rvitmax1xN                      rvitmax1xN
#define Lvitmax2xN                      lvitmax2xN
#define Rvitmax2xN                      rvitmax2xN
#define Bitmux_shr                      bitmux_shr
#define Bitmux_shl                      bitmux_shl


#define Cadd_shr_frN     			    cadd_shr_frN
#define Csub_shr_frN                    csub_shr_frN
#define Cadd_frN                        cadd_frN
#define Cadd_frM                        cadd_frM
#define Csub_frN                        csub_frN
#define Csub_frM                        csub_frM
#define Cmlt_frN                        cmlt_frN
///////////////////////// Add by wangnaibo 2006-09-05
#define Cmlt_frN2                       cmlt_frN2
///////////////////////// Add end
#define Cmlt_frM                        cmlt_frM
#define Cmls_frM                        cmls_frM
#define Conjmlt_frN                     conjmlt_frN
#define Conjmlt_frM                     conjmlt_frM
#define Conjmlt_fr40                    conjmlt_fr40
#define Conjmlt_ashift_cfrN             conjmlt_ashift_cfrN
#define Conj_frN                        conj_frN
#define Cmac_frN                        cmac_frN
#define Cmac_frM                        cmac_frM
#define Cmac_fr40                       cmac_fr40
#define Cmsu_frN                        cmsu_frN
#define Cmsu_frM                        cmsu_frM
#define Csqu_frN                        csqu_frN
#define Csqu_frM                        csqu_frM
#define Csqu_ashift_frM                 csqu_ashift_frM
#define Cdst_frN                        cdst_frN
#define Cdst_frM                        cdst_frM
#define Conjmac_frN                     conjmac_frN
#define Conjmac_frM                     conjmac_frM
#define Conjmac_fr40                    conjmac_fr40

#define Cshl_frN                        cshl_frN
#define Cshr_frN                        cshr_frN
#define Cshl_frM                        cshl_frM
#define Cshr_frM                        cshr_frM
#define Cexpadj_frN                     cexpadj_frN
#define Cexpadj_frM                     cexpadj_frM//add by qiyingjie @20131115 Enh00000321
#define Cnegate_frN                     cnegate_frN
#define Cmls_frN                        cmls_frN
#define Cmls_iN                         cmls_i2xN
#define Cmlt_iN                         cmlt_iN
#define Cdiv_frN                        cdiv_frN
#define Cdivr_frN                       cdivr_frN

#define Divs_fr1xN                      divs_fr1xN
#define Divs_fr1xM                      divs_fr1xM
// added by yanwei, 2011-02-22
#define Divs_fr1xM_TH                   divs_fr1xM_TH
// end
#define Divs_i1xN                       divs_i1xN
#define Divs_i1xM                       divs_i1xM
#define Sqrt_fr1xN                      sqrt_fr1xN
#define Ssqrt_TH                        ssqrt_TH
//#define Rsqrt_frN                     rsqrt_frN
#define Isqrt                           isqrt
#define Cos_frN_rad                     cos_frN_rad
#define Cos_frN                         cos_frN
#define Sin_frN                         sin_frN
#define Set_bit_width                   set_bit_width
#define BitWidth                        bitWidth

#endif  //
cmplx_frN cadd_shr_frN(cmplx_frN a, cmplx_frN b, uint8 nbit);
fractN round_add_int32(fractN v1, fractN v2, uint8 nbit);
cmplx_frN csub_shr_frN(cmplx_frN a, cmplx_frN b, uint8 nbit);
fractN round_sub_int32(fractN v1, fractN v2, uint8 nbit);

#endif  // /* __LIB_ARITH_H__ */


